package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.BenZuKBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_xiaozu.view.*

/**
 * Created by Administrator on 2017/11/10/010.
 * 作者：刘洋
 */
class XiaoZuKAdapter(var xiaozuList : MutableList<BenZuKBean>, val context :Context) : BaseAdapter(){
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_xiaozu,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        val xiaoZuBean=xiaozuList[position]
        Myutil.settv(xiaoZuBean.wu_name,h.NameTv)
        Myutil.settv(xiaoZuBean.gangwei_name,h.gangWeiTv)
        Myutil.settv(xiaoZuBean.work_number,h.gongHaoTv)
//        h.NameTv.text=xiaoZuBean.wu_name
//        h.gangWeiTv.text=xiaoZuBean.gangwei_name
//        h.gongHaoTv.text=xiaoZuBean.work_number
        h.xiShuTv.text=xiaoZuBean.coefficient+"/"+xiaoZuBean.coefficient_total
        return v
    }

    override fun getItem(position: Int): Any {
        return xiaozuList[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return xiaozuList.size
    }

    override fun areAllItemsEnabled(): Boolean {
        return false
    }

    override fun isEnabled(position: Int): Boolean {
        return false
    }

    class Header(var v : View){
        var gongHaoTv=v.GongHaoTv
        var NameTv=v.NameTv
        var gangWeiTv=v.GangWeiTv
        var xiShuTv=v.XiShuTv
    }
}